package com.yiqi.zhiyuan.feature.order.model;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.yiqi.zhiyuan.entity.dto.ComfirmTripDTO;
import com.yiqi.zhiyuan.entity.dto.TaskDTO;
import com.yiqi.zhiyuan.entity.vo.EndPushVO;
import com.yiqi.zhiyuan.entity.vo.OrderVO;
import com.yiqi.zhiyuan.feature.order.contract.OrderInfoContract;
import com.yiqi.zhiyuan.feature.order.dependencies.info.DaggerOrderInfoModelComponent;
import com.yiqi.zhiyuan.framework.api.ApiLib;
import com.yiqi.zhiyuan.framework.api.OrderApi;

import javax.inject.Inject;

import io.reactivex.Observable;

/**
 * @ProjectName: ZhiYuan
 * @Description: 注册model
 * @Author: lijuwen
 * @CreateDate: 2019/3/13 13:07
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/13 13:07
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class OrderInfoModel implements OrderInfoContract.Model {
    @Inject
    OrderApi api;

    public OrderInfoModel() {
        DaggerOrderInfoModelComponent.builder().apiComponent(ApiLib.apiComponent()).build().inject(this);
    }

    @Override
    public Observable<EndPushVO> doEndTask(TaskDTO taskDTO) {
        return api.endTask(taskDTO).compose(RxDataProcessFactory.<EndPushVO>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> doStartTask(TaskDTO taskDTO) {
        return api.startTask(taskDTO).compose(RxDataProcessFactory.<String>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<OrderVO> doSelectDriverOrderDetails(TaskDTO taskDTO) {
        return api.selectDriverOrderDetails(taskDTO).compose(RxDataProcessFactory.<OrderVO>dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> doArriveAtLocation(TaskDTO taskDTO) {
        return api.arriveAtLocation(taskDTO).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> doPassengersGettingOnBus(TaskDTO taskDTO) {
        return api.passengersGettingOnBus(taskDTO).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<OrderVO> doGoNow(TaskDTO taskDTO) {
        return api.goNow(taskDTO).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }

    @Override
    public Observable<String> doComfirmTrip(ComfirmTripDTO comfirmTripDTO) {
        return api.comfirmTrip(comfirmTripDTO).compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer());
    }
}

